<!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
		<title>详情</title>
		<!--标准mui.css-->
		<link rel="stylesheet" href="css/mui.min.css">
		<link rel="stylesheet" href="css/mui.css" />

		<link rel="stylesheet" href="css/base.css" />
		<link rel="stylesheet" href="css/iconfont.css" />
		<link rel="stylesheet" href="css/commodity-details.css" />
		<link rel="stylesheet" href="css/all.css" />
	</head>

	<body>
		<div>
			<div class="heads">
				<span href="javascript:;" onclick="go()">
        			<i class="iconfont icon-iconfontjiantou1"></i>
				</span>
				<div class="detail">
					<span>详情</span>
					<a onclick="location.href='./recommend.html'">
						<span class="details">推荐</span>
					</a>
				</div>
			</div>
			<div class="middle-two">
				<!--<div class="show">
					<img src="img/3152.png" alt="">
				</div>
				<div class="topic">
					<p>鲁美诺斯/3152银海/军用/商务/男士</p>
					<p>LUMINOX十年一剑，全球限量五百块。200m潜水蓝宝石镜面，25年氚管发光，军用商务两栖军表。</p>
					<p>瑞士制造，美海豹突击队指定军用手表。外观硬朗帅气，防摔防砸防震，型男必备良品。</p>
					<p>￥4999</p>
					<span>0.1元</span><span>/单</span><span>河南郑州</span>
				</div>
				<div class="address">
					<i class="iconfont icon-icon-test"></i>
					<span>河南省郑州市郑东新区商都路通泰路交叉口向南50米路东</span>
					<a href="">
						<i class="iconfont icon-dianhua"></i>
					</a>
				</div>
				<div class="merchant">
					<div class="store row">
						<div class="merchants">
							<img src="img/chengshi.png" alt="">
						</div>
						<i class="stores">沈阳城市猎人户外军品之家</i>
						<a onclick="location.href='./business-detail.html'">
							<div class="stores-one">
								<p>进店看看</p>
							</div>
						</a>
					</div>

				</div>
				<div>
					<div class="product">
						<p>商品详情</p>
					</div>
					<p class="products">LUMINOX十年一剑，全球限量五百块。200m潜水蓝宝石镜面，25年氚管发光，军用商务两栖军表。</p>
					<div class="shangpin">
						<img src="img/biao.png" alt="">
					</div>
				</div>-->
			</div>
			<div class="footers">
				<ul class="flex" id="bottom">
					<li>
						<a href="">
							<i class="iconfont icon-lianjie"></i>
							<i>查看原链接</i>
						</a>
					</li>
					<li onclick="register()">

						<i class="iconfont icon-iconfontfenxiang"></i>
						<i>立即分享</i>

					</li>
				</ul>
			</div>
		</div>
		<script src="js/jquery.js"></script>
		<!--分享 mui-->
		<script src="js/mui.min.js"></script>
		<script src="js/mui.zoom.js"></script>

		<script src="js/x_rem.js"></script>
		<script src="js/all.js"></script>

		<script>
			var title = ""; //保存广告标签,用来分享标题
			var picture = ""; //保存广告图片，用来分享图片
			var userName = "";

			function commodity() {
				var data = {
					browseTaskId: GetQueryString("browseTaskId"),

				};

				var success = (data) => {
					title = data.browseTask.title;
					picture = data.browseTask.picture;
					userName = data.phone;
					 console.log(picture);
					var html = "";
					html += `
						<div class="show">
							<img src="${data.browseTask.picture}" alt="">
						</div>
						<div class="topic">
							<p>${data.browseTask.title}</p>
							<p>${data.browseTask.briefIntroduction}</p>
 							<p>￥${data.browseTask.totalMoney}</p>
							<span>${data.browseTask.oneMoney}元</span><span>/单</span><span>河南郑州</span>
						</div>
						<div class="address">
							<i class="iconfont icon-icon-test"></i>
							<span>河南省郑州市郑东新区商都路通泰路交叉口向南50米路东</span>
							<a href="">
								<i class="iconfont icon-dianhua"></i>
							</a>
						</div>
						<div class="merchant">
							<div class="store row">
								<div class="merchants">
									<img src="${data.portrait}" alt="">
								</div>
								<i class="stores">${data.companyName}</i>
								<a onclick="location.href='./business-detail.html?userName=${data.userName}'">
									<div class="stores-one">
										<p>进店看看</p>
									</div>
								</a>
							</div>
		
						</div>
						<div>
							<div class="product">
								<p>商品详情</p>
							</div>
							<p class="products">LUMINOX十年一剑，全球限量五百块。200m潜水蓝宝石镜面，25年氚管发光，军用商务两栖军表。</p>
							<div class="shangpin">
								<img src="img/biao.png" alt="">
							</div>
						</div>
			
					`

					$(".middle-two").html(html);
				};

				Hajax("post", "/browseTask/findOneBrowseTask", data, success);

			};

			commodity();  //调用

			//点击分享图标时调用
			function register() {

				var site = Url + "/pc/details.html?id=" + GetQueryString("id") + "&userName=" + userName;

				var data = {

				};

				var success = () => {
					shareHref(); //调用分享
				};

				Hajax("post", "/user/isLog", data, success);

				console.log(Url + "/pc/commodity.html?browseTaskId=" + GetQueryString("browseTaskId") + "&userName=" + userName);

			}

			//分享

			mui.init({
				swipeBack: true //启用右滑关闭功能
			});

			var Intent = null,
				File = null,
				Uri = null,
				main = null;
			var shares = null;
			var shareImageUrl = '';
			mui.plusReady(function() {
				updateSerivces();
				if(plus.os.name == "Android") {
					Intent = plus.android.importClass("android.content.Intent");
					File = plus.android.importClass("java.io.File");
					Uri = plus.android.importClass("android.net.Uri");
					main = plus.android.runtimeMainActivity();
				}
			})
			/**
			 * 更新分享服务
			 */
			function updateSerivces() {
				plus.share.getServices(function(s) {
					shares = {};
					for(var i in s) {
						var t = s[i];
						shares[t.id] = t;
					}
					outSet("获取分享服务列表成功");
				}, function(e) {
					outSet("获取分享服务列表失败：" + e.message);
				});
			}
			/**
			 * 分享操作
			 */
			function shareAction(id, ex) {
				console.log('id = ' + id);
				console.log('ex = ' + ex);
				console.log('shares[id]' + shares[id]);
				var s = null;
				if(!id || !(s = shares[id])) {
					outLine("无效的分享服务！");
					return;
				}
				if(s.authenticated) {
					outSet("---已授权---");
					shareMessage(s, ex);
				} else {
					outSet("---未授权---");
					s.authorize(function() {
						shareMessage(s, ex);
					}, function(e) {
						outLine("认证授权失败");
					});
				}
			}

			/**
			 * 发送分享消息
			 */

			//			var site = Url+"/pc/details.html?id="+GetQueryString("id")+"&userName="+userName;

			function shareMessage(s, ex) {

				var msg = {
					content: '分享-详情',
					href: Url + "/pc/commodity.html?browseTaskId=" + GetQueryString("browseTaskId") + "&userName=" + userName,
					title: '蒲公英',
					content: title,
					thumbs: [picture], // http://img3.3lian.com/2013/v10/4/87.jpg
					pictures: ['images/xz.png'], //http://img3.3lian.com/2013/v10/4/87.jpg
					extra: {
						scene: ex
					}
				};
				s.send(msg, function() {
					outLine("分享成功!");
				}, function(e) {
					outLine("分享失败!");	 
				});
			}
			/**
			 * 分享按钮点击事件
			 * 注意这里的这些id值
			 */
			function shareHref() {
				var ids = [{
							id: "weixin",
							ex: "WXSceneSession" /*微信好友*/
						},
						{
							id: "weixin",
							ex: "WXSceneTimeline" /*微信朋友圈*/
						},
						{
							id: "qq" /*QQ好友*/
						}
					],
					bts = [{
							title: "发送给微信好友"
						},
						{
							title: "分享到微信朋友圈"
						},
						{
							title: "分享到QQ"
						}
					];
				plus.nativeUI.actionSheet({
						cancel: "取消",
						buttons: bts
					},
					function(e) {
						var i = e.index;
						console.log('i = ' + i);
						if(i > 0) {
							shareAction(ids[i - 1].id, ids[i - 1].ex);
						}
					}
				);
			}
			// 控制台输出日志
			function outSet(msg) {
				console.log(msg);
			}
			// 界面弹出吐司提示
			function outLine(msg) {
				mui.toast(msg);
			}
		</script>
	</body>

</html>